<template>
  <div class="loginContainer">
    <!-- 登录 -->
    <div class="loginWrap">
      <div class="login">
        <div class="loginform">
          <ul class="tab clearFix">
            <li>
              <a href="##" class="cur" style="border-right: 0">扫描登录</a>
            </li>
            <li>
              <a href="##" class="current">账户登录</a>
            </li>
          </ul>

          <div class="content">
            <form>
              <!-- 手机号 -->
              <div class="input-text clearFix">
                <span></span>
                <input
                  type="text"
                  placeholder="邮箱/用户名/手机号"
                  v-model="phone"
                />
              </div>
              <!-- 密码 -->
              <div class="input-text clearFix">
                <span class="pwd"></span>
                <input
                  type="text"
                  placeholder="请输入密码"
                  v-model="password"
                />
              </div>
              <!-- 底部自动登录 -->
              <div class="setting clearFix">
                <label class="checkbox inline">
                  <input name="m1" type="checkbox" value="2" checked="" />
                  自动登录
                </label>
                <span class="forget">忘记密码？</span>
              </div>
              <button class="btn" @click.prevent="goUserLogin">
                登&nbsp;&nbsp;录
              </button>
              <router-link class="register "  to="/register">立即注册</router-link>
            </form>
            
            
          </div>
        </div>
      </div>
    </div>

    
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      phone: "", //用户输入的手机号,
      password: "", //用户输入的代码
    };
  },
  methods: {
    // 登录回调函数
    async goUserLogin() {
      try {
        let { phone, password } = this;
        phone &&
          password &&
          (await this.$store.dispatch("userLogin", { phone, password }));
          // 跳转query参数地址
          let toPath = this.$route.query.redirect || "/home"
          this.$router.push(toPath) 
      } catch {
        console.log("Login failed");
      }
    },
  },
};
</script>

<style scoped lang="less">
.loginContainer {
  margin-top: 30px;
//   background-color: #e92067;
  .loginWrap {
    height: 487px;
    .login {
      
      width: 1220px;
      height: 487px;
      margin: 0 auto;
    //   background: url(./images/2.png) no-repeat;
    }
    .loginform {
    
      width: 420px;
      height: 406px;
      box-sizing: border-box;
      background: #fff;
      float: right;
      top: 45px;
      position: relative;
      right: 400px;
      padding: 20px;
      .tab {
        li {
          width: 50%;
          float: left;
          text-align: center;

          a {
            width: 100%;
            display: block;
            height: 50px;
            line-height: 50px;
            font-size: 20px;
            font-weight: 700;
            color: #333;
            border: 1px solid #ddd;
            box-sizing: border-box;
            text-decoration: none;
          }

          .current {
            border-bottom: none;
            border-top-color: #28a3ef;
            color: #333;
          }
          .cur:hover{
            color:#ff6700 !important;
          }
          .current:hover{
            color:#ff6700 !important;
          }
        }
      }
      .content {
        width: 380px;
        height: 316px;
        box-sizing: border-box;
        border: 1px solid #ddd;
        border-top: none;
        padding: 18px;

        form {
          margin: 15px 0 18px 0;
          font-size: 12px;
          line-height: 18px;

          .input-text {
            margin-bottom: 16px;

            span {
              float: left;
              width: 37px;
              height: 32px;
              border: 1px solid #ccc;
              background: url(./images/icons.png) no-repeat -10px -201px;
              box-sizing: border-box;
              border-radius: 2px 0 0 2px;
            }

            .pwd {
              background-position: -72px -201px;
            }

            input {
              width: 302px;
              height: 32px;
              box-sizing: border-box;
              border: 1px solid #ccc;
              border-left: none;
              float: left;
              padding-top: 6px;
              padding-bottom: 6px;
              font-size: 14px;
              line-height: 22px;
              padding-right: 8px;
              padding-left: 8px;

              border-radius: 0 2px 2px 0;
              outline: none;
            }
          }

          .setting {
            label {
              float: left;
            }

            .forget {
              float: right;
            }
          }

          .btn {
            background-color: #ff6700;
            padding: 6px;
            border-radius: 0;
            font-size: 16px;
            font-family: 微软雅黑;
            word-spacing: 4px;
            border: 1px solid #ff6700;
            color: #fff;
            width: 100%;
            height: 36px;
            margin-top: 25px;
            outline: none;
          }
          .register {
            width: 100%;
            margin-top: 10px;
            float: right;
            font-size: 16px;
            line-height: 36px;
            text-align: center;
            text-decoration: underline;
            border: 1px solid #ff6700;
             text-decoration: none;
          }
          .register:hover {
            color: #333 !important;
            text-decoration: none;
          }
        }
      }
    }
  }
}
</style>